﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Weazel.Willows.Model
{
	public abstract class Channel
		: HierarchicalEntity
	{
		private string uniqueName;
		public string UniqueName
		{
			get { return uniqueName; }
		}

		private TypeRegistry typeRegistry;
		public TypeRegistry TypeRegistry
		{
			get { return typeRegistry; }
		}

		protected Type type;
		public Type Type
		{
			get { return type; }
		}

		public int BitWidth
		{
			get { return type.BitWidth; }
		}

		public abstract void Verify(Model model);

		public abstract Module GetWritingDatapath();
		public abstract List<Module> GetReadingDatapaths();

		public Channel(Module parent, TypeRegistry typeRegistry, Type type, string name, string uniqueName)
			: base(parent, name)
		{
			this.typeRegistry = typeRegistry;
			this.type = type;
			this.uniqueName = uniqueName;
		}

		public abstract void Refine(RefinedModel.Model model);

		public abstract void WriteChannelHierarchy(System.CodeDom.Compiler.IndentedTextWriter textWriter);
	}
}
